package tests;

import static org.junit.Assert.*;

import org.junit.Test;

import recipe.Ingredient;

public class IngredientTest {

	@Test
	public void testParseAmount() {
		String blank = "";
		String numbers = "1234";
		String letters = "abcd";
		String charDec = "a.";
		String decChar = ".l";
		String decFrac = "45/892.34";
		
		String fraction = "3/4";
		String doublefrac = "3//9";
		String noBefore = "/10";
		String noAfter = "1/";
		
		String decimal = "1.234";
		String doubledec = "143..542";
		String noFirstDigit = ".930";
		String noLastDigit = "1.";
		String nonConDec = "64.803.7";
		
		assertTrue(
				Ingredient.parseAmount(numbers) > 0 
				&& Ingredient.parseAmount(letters) == 0 
				&& Ingredient.parseAmount(decimal) > 0
				&& Ingredient.parseAmount(fraction) > 0
				&& Ingredient.parseAmount(doubledec) == 0
				&& Ingredient.parseAmount(blank) == 0
				&& Ingredient.parseAmount(noFirstDigit) == 0
				&& Ingredient.parseAmount(noLastDigit) == 0
				&& Ingredient.parseAmount(doublefrac) == 0
				&& Ingredient.parseAmount(noBefore) == 0
				&& Ingredient.parseAmount(noAfter) == 0
				&& Ingredient.parseAmount(charDec) == 0
				&& Ingredient.parseAmount(decChar) == 0
				&& Ingredient.parseAmount(nonConDec) == 0
				&& Ingredient.parseAmount(decFrac) == 0
		);
		
		assertEquals("should be equal", 1.2, Ingredient.parseAmount("1.2"), 0);
		assertEquals("should be equal", 0.75, Ingredient.parseAmount("3/4"), 0);
	}

}
